home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr13 / veced100.zip / CONVDEFS.H < prev    next >
Text File  |  1995-01-19  |  6KB  |  176 lines

  1. //************************************************************************
  2. //************************************************************************
  3. // The following data structures are designed for easier use by users of
  4. // the program that want to create their own conversion utility.  Code is
  5. // included in the Vecedit package which will convert Vecedit objects to
  6. // this format (in C/ C++).  This code should really help (it is much
  7. // easier to process a binary file than it is to parse a text file).  The
  8. // format is based on a format given me by Dick Verweil (sp?).
  9.  
  10. // The basic data necessary to represent an object are:
  11. //    POINTS = Set of vertices of object, stored as longs (X,Y,Z).
  12. //    NORMALS= Set of precalculated vector normals for the object.
  13. //    GROUP POINTS= Set of points to be used for depth sorting.
  14. //    FACES = Set of faces (polygons)--see structure below.
  15. //    FACE POINT LISTS = Lists of vertices which belong to specific
  16. //               faces.
  17.  
  18. // In addition, for texture/ gourad shading, the following are needed:
  19. //    VERTEX NORMALS  = Vertex normals for gourad shading
  20. //    GOURAD VERTICES = Set of information correlating vertices of faces
  21. //        to vertex normals.
  22. //    TEXTURE VERTICES = Set of information correlating vertices of a
  23. //        face to coordinates in the bitmap.
  24.  
  25. // A quick note about offsets:  offsets are divided by the size of the
  26. // respective data structure.  Thus the offset given is the actual number
  27. // of the piece of data.  For example, the offset of the fourth vertex
  28. // (12 byte data structure) would be "3", NOT "36" or "9".
  29.  
  30. // Texture map vertex information (for interpolation)
  31.  
  32. typedef struct
  33.     {
  34.     int x;            // x location in bitmap of vertex
  35.     int y;            // y location in bitmap of vertex
  36.     } outtex;
  37.  
  38. // Gourad shading vertex information (for interpolation)
  39.  
  40. typedef struct
  41.     {
  42.     unsigned vertnormal;        // offset of vertex normal
  43.     } outgou;
  44.  
  45. // Face (polygon) information
  46.  
  47. typedef struct
  48.     {
  49.     char     color;            // The color (0..255)
  50.     char     shadeflag;        // 1=texture map,   2=gourad shade
  51.                     // 0=no special shading
  52.  
  53.     unsigned numpoints;        // number of vertices
  54.     unsigned *pointarray;        // pointer to vertex list (set of
  55.                     // offsets in the vertex list)
  56.     unsigned normalvec;        // offset of normal vector of poly
  57.     unsigned grouppt;        // offset of group point of poly
  58.  
  59.     outgou     *gouvee;        // list of gourad vertices
  60.     outtex     *texvee;        // list of texture map coordinates
  61.     char     *bmp;           // pointer to bitmap
  62.     } face;
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. //************************************************************************
  71. //************************************************************************
  72. // The structures below are internal to my program.  Caution:  these are
  73. // difficult to understand (especially considering you don't know how my
  74. // code works!).
  75. //************************************************************************
  76. //************************************************************************
  77.  
  78. typedef struct
  79.     {
  80.     long    x;
  81.     long    y;
  82.     } bigvert;
  83.  
  84. typedef struct
  85.     {
  86.     unsigned v[2];            // normalized vertex indexes
  87.     unsigned poly[2];        // polys connected to edge
  88.     unsigned texpoint[2];        // pointers to texture edges
  89.     } rawedgeverts;
  90.  
  91. typedef struct
  92.     {
  93.     unsigned char colorvalue;
  94.     unsigned char backfill;
  95.     long D;
  96.     unsigned normvecoff;        // offset in normal vector array
  97.     unsigned point;            // offset in translated array
  98.     unsigned texflag;        // flag saying if polygon is texture
  99.     void far *texpoly;        // pointer to texpoly
  100.     } polystruc;
  101.  
  102.  
  103. // Following is a set of structures which will be used for drawing texture
  104. // mapped polygons.
  105.  
  106. typedef struct
  107.     {
  108.     long     x;            // current coordinates of edge
  109.     long     y;            // in bitmap
  110.     long     dx;            // increments for each coordinate
  111.     long     dy;            // while advancing down edge
  112.     long     g;            // gourad shading value
  113.     long     dg;            // gourad shading increment
  114.     void far *texpo;        // pointer to texpoly
  115.     int     edgeflag;        // flag saying type of texture edge
  116.                     // first bit (1) indicates texture
  117.                     // second bit (2) indicates gourad
  118.     unsigned statloc;        // location of texstats
  119.     } texedge;
  120.  
  121.     // The following data structure is used to hold information for the
  122.     // various boundaries of a texture edge (corners and max values)
  123.     // This data structure will be used by the preproc function
  124.  
  125. typedef struct
  126.     {
  127.     int      xcorn1;        // x and y coordinates of vertex
  128.     int     ycorn1;        // corresponding to v1
  129.     int     xcorn2;        // x and y coordinates of vertex
  130.     int     ycorn2;        // corresponding to v2
  131.     int     xmax;            // maximum possible x and y values
  132.     int     ymax;            // in texture map (for rounding)
  133.     unsigned goustruc[2];        // gourad vertex offsets
  134.     } texstats;
  135.  
  136.  
  137. typedef struct
  138.     {
  139.     unsigned texture;        // pointer to texture map
  140.     unsigned leftpix;        // pixel location of left edge
  141.     unsigned leftedge;        // offset of left texture edge
  142.     unsigned rightpix;        // pixel location of right edge
  143.     unsigned rightedge;        // offset of right texture edge
  144.     long     xincr;            // x and y increments to get from
  145.     long     yincr;            // point "A" to point "B"
  146.     unsigned backfill;        // same as flag for regular poly
  147.     unsigned edgesgot;        // number of edges added to texpoly
  148.     long     gincr;            // gourad shading increment
  149.     } texpoly;
  150.  
  151.     // the following data structure will hold a vertex normal offset,
  152.     // raw vertex offset, and a corresponding gourad color value
  153.  
  154. typedef struct
  155.     {
  156.     int      gvalue;        // calculated gourad shade
  157.     unsigned vertoff;        // 3D rotated vertex offset
  158.     unsigned vertnormoff;        // vertex normal offset
  159.     } gouvert;
  160.  
  161.  
  162. typedef struct
  163.     {
  164.     unsigned ps;            // number of polygons in object
  165.     unsigned es;            // number of edges in object
  166.     unsigned vs;            // number of vertices in object
  167.     } numstuff;
  168.  
  169. typedef struct
  170.     {
  171.     unsigned vn;            // number of vertex normals
  172.     unsigned tp;            // number of texture polygons
  173.     unsigned te;            // number of texture edges
  174.     } numgoustuff;
  175.  
  176.